<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>reverse和sort</title>
    </head>
    <body>
        <script src="index.js" type="text/javascript" charset="utf-8"></script>
        <script type="text/javascript">
            //reverse
         /*    var arr = ["鬼谷","农家","法家","儒家","道家","墨家"];
            console.log(arr);
            arr.reverse();
            console.log(arr); */

            //sort
        /*     var arr = ["12","23","123","234","56"];
            var newArr = arr.sort();
            console.log(newArr);
            
            var arr = [12, 123, 23, 66, 56];
            var newArr1 = arr.sort();
            console.log(newArr1);

            var fn = function(a,b){
                if(a>b){
                    return 1;
                }else{
                    return -1;
                }
            }

            var newArr2 = arr.sort(fn);
            console.log(newArr2); */



            //易点租例子
            var hotModel = yidianzuData.data.hotModel;
            console.log(hotModel);

            var newArr = hotModel.sort(function(a,b){
                if(parseFloat(a.minRent) >parseFloat(b.minRent)){
                    return -1;
                }else{
                    return 1;
                }
            });

            console.log(newArr);

            for(var k = 0;k < newArr.length;k++){
                document.write("<h2>"+newArr[k].title+"</h2>");
                document.write("<p>"+newArr[k].minRent+"</p>");
                document.write("<img src='"+newArr[k].url+"'>");
                document.write("</div>");
            }


        </script>
    </body>
</html>